#include <iostream>
#include <vector>
#include <set>

using namespace std;

class Solution {
public:
    int missingNumber(vector<int>& nums) {
        int ret = 0;
        int length = nums.size();

        set<int> numsSet;
        for (int idx = 0; idx <= length; idx++) {
            numsSet.insert(idx);
        }

        for (int idx = 0; idx < length; idx++) {
            if (numsSet.find(nums[idx]) != numsSet.end()) {
                numsSet.erase(nums[idx]);
            }
        }
        ret = *numsSet.begin();
        return ret;
    }
};

int main()
{
    Solution s;
    vector<int> vt{0};
    cout << s.missingNumber(vt) << endl;
    return 0;
}